import matplotlib.pyplot as plt
import numpy as np

fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(12, 5))

all_data = [np.random.normal(0, std, 100) for std in range(6, 10)]

# fig = plt.figure(figsize=(8,6))

axes.violinplot(all_data,
                   showmeans=False,
                   showmedians=True
                   )
axes.set_title('violin plot')



# adding horizontal grid lines

axes.yaxis.grid(True)
axes.set_xticks([y + 1 for y in range(len(all_data))], )
axes.set_xlabel('xlabel')
axes.set_ylabel('ylabel')

plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))],
         xticklabels=['x1', 'x2', 'x3', 'x4'],
         )

plt.show()

# import torch
#
# import numpy as np
# import torchvision.models as models
#
# resnet18 = models.resnet18(pretrained=True)
#
# def resize_tensor(tensor):
#     length = 1
#     shape = np.shape(tensor)
#     length = np.prod(shape)
#     flat_array = np.reshape(tensor, length)
#     return flat_array
#
#
# def get_model_variable(para_list, name_list):
#     output = np.array([])
#     for name in name_list:
#         ret = resize_tensor(np.array(para_list[name]))
#         output = np.r_[output, ret]
#
#     return output
#
# def get_model_params():
#     parm = {}
#     name_list = []
#     for name, parameters in models.resnet18().named_parameters():
#         # print(name,':',parameters.size())
#         parm[name] = parameters.detach().numpy()
#         name_list.append(name)
#
#     weights_ = get_model_variable(parm, name_list)
#     return weights_
#
# print(get_model_params())
